bspwm not bar

tuesday, 13 january 2015

one of bspwm’s alluring features is the gymnastics it can perform with simple shell scripts.

Status bars identifying the desktop in focus and displaying system information are common amongst tiling window managers because desktop information managers like conky would typically be hidden by opened tiles. Thus, in order to provide persistent visual system information, a panel area is reserved on the screen, usually positioned at the top (xmonad) or bottom (notion) of the display.

Status bars typically have their content confined to a single row of textual information with as small a font as is readable. The oft displayed system stats (cpu utilization, temperature, network status, weather forecast, etc.) can create a certain amount of visual noise as it is updated—which conflicts with my overall preference for distraction free work (wandering eyes are always checking the state of the system).

Enter bspwm’s dynamic display management.

Unadorned desktop

Desktop, with conky panel

Instead of packing a lot of system information into a single horizontal status bar, I use a vertical conky panel in all its graphical glory whose visibility can be toggled on and off with all the window spaces adjusted accordingly! System information at my finger tips, otherwise, an elegant distraction free desktop when writing.

In this case, the graphical conky panel occupies some screen real estate on the right hand side of the primary monitor, but on a 30” cinema display, its impact is negligible. The visual graphs provide much more information at a glance without needing to read the values they represent—a picture is worth a thousand words.

desktop padding rules

what makes this configuration different from the original conky panel implementation described here, is that some fine tuning of the window placement is done to provide a more visually appealing balance with the transparency mode of the conky panel.

In particular, when the conky panel is visible:

  • Full screen mode only occupies the remaining screen real estate to the right of the cony panel, as opposed to, filling the entire physical display with the conky panel covering the right hand content of the window.
  • In tiled mode, the right hand window_gap is effectively 0 (relative to the left edge of the conky panel), which is achieved by adjusting the display’s right_padding a window_gap to the right of the left edge of the conky panel! The calculation is better understood below in the shell script..

conky-padding

#!/bin/sh maximum_width=$(grep 'maximum_width' ~/.conkyrc | cut -d' ' -f2) border_margin=$(grep 'border_outer_margin' ~/.conkyrc | cut -d' ' -f2) function shadow() { pidof compton >/dev/null && echo 24 || echo 0 } function tiled() { D=$(bspc query –tree –monitor DVI-1 | grep ‘T - *’ | awk ‘{print $1}’) G=$(bspc config –desktop $D window_gap) echo “$maximum_width + $border_margin * 2 - $G + 2 + $(shadow)” | bc } function monocle() { echo “$maximum_width + $border_margin * 2 + $(shadow)” | bc } if xdotool search --onlyvisible --classname 'Conky'; then if bspc query –tree –monitor DVI-1 | grep -q ‘ M - *’; then bspc config -m DVI-1 right_padding $(monocle) else bspc config -m DVI-1 right_padding $(tiled) fi else bspc config -m DVI-1 right_padding 0 fi

A two pixel adjustment is made in the tiling calculation—it is just something that was determined through pixel peeping. If a compositing manager is detected, the right_padding is further adjusted so conky does not to cover the shadow effect of the adjacent window!

The new desktop padding rules are enforced when the conky panel is toggled or the window gaps are adjusted!

smart conky panel

alt + backslash if [[ $(xrandr | grep ‘*’ | cut -dx -f1 | sort | tail -1) -gt 1024 ]]; then if xdotool search –onlyvisible –classname ‘Conky’ windowunmap; then bspc config -m DVI-1 right_padding 0; else if ! xdotool search –classname ‘Conky’ windowmap; then conky -q -c ~/.conkyrc & xdotool search –sync –onlyvisible –classname ‘Conky’; fi; fi; conky-padding; else xdotool search –onlyvisible –classname ‘Conky’ windowunmap || xdotool search –classname ‘Conky’ windowmap || conky -q -c ~/.conkyrc & fi

The netbook screen with its small 1024x600 display is exempt from the dynamic padding rules—an arbitrary decision to not shrink tiled windows on a display that small.

Conky panel, on top of 1024x600 window

overlapping conky panel

alt + shift + backslash xdotool search –onlyvisible –classname ‘Conky’ windowunmap \ || xdotool search –classname ‘Conky’ windowmap \ || conky -q -c ~/.conkyrc &

reset conky panel

alt + ctrl + shift + backslash killall conky && conky -q -c ~/.conkyrc & conky-padding

conky bits

the .conkyrc configuration file displays the names of the visible desktops of the multihead setup in the top right corner of the panel. The active desktop is indicated by the larger font of the left/right desktop number pair—the offsets are specific to the conky width, margin and font—with the name of the active application in focus below..

${if_match "${exec bspc query -M -m focused}" == "DVI-0"} ${voffset -213}${font Ubuntu:size=48,weight:normal}${color5}${offset 136}${exec bspc query -D -d focused}${font Ubuntu:size=16,weight:normal}${color4}${exec bspc query -T -m last|grep $'^\t*[0-9].*\*'|sed 's/\t\([0-9]\) .*/\1/'} ${voffset -72} ${else} ${voffset -213}${font Ubuntu:size=48,weight:normal}${color4}${offset 136}${font Ubuntu:size=16,weight:normal}${exec bspc query -T -m last|grep $'^\t*[0-9].*\*'|sed 's/\t\([0-9]\) .*/\1/'}${voffset -46}${font Ubuntu:size=48,weight:normal}${color5}${exec bspc query -D -d focused} ${voffset -249} ${endif} ${font Ubuntu:size=7,weight:normal}${color3}${alignr}${exec [[ $(bspc query -T | grep "$(bspc query -W -w)" | wc -l) -eq 1 ]] && (bspc query -T | grep "$(bspc query -W -w)" | awk '{ print $3; }') || echo} ${voffset 106}

The clock and circular graphs are based on the conky lua functions from the popular GNOME-LOOK conky_grey and conky_orange conky configurations.

Experimenting with the window_gap on the desktop system called attention to the visual gap between the application windows and the conky panel. Conky transparency made the window_gap appear larger on the right side of the display which led to creating the conky-padding script to tuck the right window_gap under the conky panel while respecting the dynamic window_gap!

status bar

i still use bspwm’s conventional status bar (which, of course, I have configured so that it can also be toggled on and off!) on my netbook and secondary monitor. It is darkly themed, at the bottom of the screen, containing only the active application title, desktop and date/time indicator. It is minimalist to the extreme for status bars but augments the conky panel with the list of available desktops per monitor, including desktops containing hidden windows.

Call me a nut bar..

»»  bspwm

show      comment ?